﻿#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using JigLibX.Collision;
using JigLibX.Physics;
using JigLibX.Geometry;
using JigLibX.Math;
using Microsoft.Xna.Framework.Graphics;
#endregion

namespace ImportModelFromRhino.PhysicObjects
{
    class CasettaDelMicioObject : PhysicObject
    {
        public CasettaDelMicioObject(Game game, Model model, Vector3 position, Viewport[] viewports)
            : base(game, model, viewports)
        {
            body = new Body();
            collision = new CollisionSkin(body);
            collision.AddPrimitive(new Box(new Vector3(-8.21449f, -11.0282f, 0f), Matrix.Identity, new Vector3(17.54301f, 17.8429f, 0.571332f)), new MaterialProperties(0.8f, 0.8f, 0.7f));
            collision.AddPrimitive(new Box(new Vector3(-8.0276f, -10.1295f, 10.284f), Matrix.Identity, new Vector3(16.89327f, 17.14314f, 0.4189f)), new MaterialProperties(0.8f, 0.8f, 0.7f));
            collision.AddPrimitive(new Box(new Vector3(-7.47404f, -9.57353f, 0f), Matrix.Identity, new Vector3(1.03695f, 16.1362f, 10.4744f)), new MaterialProperties(0.8f, 0.8f, 0.7f));
            collision.AddPrimitive(new Box(new Vector3(7.22011f, -9.62351f, 0f), Matrix.Identity, new Vector3(1.03695f, 16.1362f, 10.4744f)), new MaterialProperties(0.8f, 0.8f, 0.7f));
            collision.AddPrimitive(new Sphere(new Vector3(-3.47043f, 4.06481f, 5.923565f), 2.06543f), new MaterialProperties(0.8f, 0.8f, 0.7f));

            body.CollisionSkin = this.collision;
            Vector3 com = SetMass(1.0f);
            body.MoveTo(position, Matrix.CreateRotationX(-MathHelper.PiOver2));
            //collision.ApplyLocalTransform(new Transform(-com, Matrix.Identity));
            body.EnableBody();
            this.body.Immovable = true;
            //this.scale = sideLengths;
        }

        public override void ApplyEffects(BasicEffect effect)
        {
            Game.GraphicsDevice.DepthStencilState = DepthStencilState.Default;
            Game.GraphicsDevice.RasterizerState = RasterizerState.CullNone;
            Game.GraphicsDevice.BlendState = BlendState.Opaque;
            //effect.DiffuseColor = color;
        }
    }
}
